- /* sdfhypbc.cpp by K.Tsuru */
- // function ID 3300 DRADIX
- /*****************************************************************************
- SDouble class
- It provides the hyperbolic functions.
- cosh(x) and sinh(x) is set "ch" and "sh", respectively.
- ******************************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- static SDouble sx = 0.0, scosh = 1.0, ssinh = 0.0;
-
- SDouble CoshBS(const SDouble& x) {
- SDouble c, s;
- Hyperbolic(x, c, s);
- return c;
- }
- SDouble SinhBS(const SDouble& x) {
- SDouble c, s;
- Hyperbolic(x, c, s);
- return s;
- }
- SDouble TanhBS(const SDouble& x) {
- SDouble c, s;
- Hyperbolic(x, c, s);
- return s*DReciprocal(c); // s/c
- }
- void Hyperbolic(const SDouble& x, SDouble& ch, SDouble& sh) {
- if(!x.Sign(3300)){ // x = 0
- ch = scosh = 1.0; sx = sh = ssinh = 0.0;
- return;
- }
- if( sx == x ) { // same value
- ch = scosh; sh = ssinh; return;
- }
- const double xMax = (double)DFIGURES*M_LN10*(double)DRADIX_EXP_MAX; // = 301759.17...
- //check the argument, e^x < DRADIX^DRADIX_EXP_MAX
- double xD = fabs( doubleD(x, 0) );
- if(xD > xMax) x.SetError(x.OVERFLOW_ERR, "Hyperbolic", 3300);
-
- SDouble r, dr;
-
- r = ExpBS(Dabs(x)); //r = e^|x|
- long ef=(long)x.MaxSize() - (long)r.NetRdxExp();
- if(ef <= 0) dr.SetZero(); //(1/r) is much less than r.
- else {
- RealSize C;
- C.SetEffFig(uint(ef)); //It can decrease the effective figures.
- dr = DReciprocal(r); //dr = 1/(e^|x|)
- C.SetEffFig(0);
- }
- ch = r + dr;
- sh = r - dr;
- if(x.Sign() <0) sh.ChangeSign();
- scosh = ch = DsDiv(ch, 2);
- ssinh = sh = DsDiv(sh, 2);
- }
sdfhypbc.cpp : last modifiled at 2016/08/07 15:48:16(1,633 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).